package site.luojie.business.code.handler;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.messaging.support.MessageBuilder;
import site.luojie.common.dto.SendVerifyCodeDto;
import site.luojie.common.mq.output.MessageVerifyCodeOutput;

/**
 * @author jie.luo
 * @since 2020/9/16
 */
@EnableBinding({
        MessageVerifyCodeOutput.class
})
public class MessageProducerHandler {

    private static final Logger LOGGER = LoggerFactory.getLogger(MessageProducerHandler.class);

    @Autowired
    private MessageVerifyCodeOutput messageVerifyCodeOutput;

    public void mqSendVerifyCode(String email, String verifyCode) {

        SendVerifyCodeDto sendVerifyCodeDto = new SendVerifyCodeDto();
        sendVerifyCodeDto.setEmail(email);
        sendVerifyCodeDto.setVerifyCode(verifyCode);

        // 发送消息
        messageVerifyCodeOutput.verifyCodeOutput().send(MessageBuilder.withPayload(sendVerifyCodeDto).build());
    }
}
